#define BE_DLL __declspec(dllexport)

#include <Input.h>

Input::Input()
{

}

Input::~Input()
{

}

void Input::LoadEvent( void )
{
	while( SDL_PollEvent( &event ) )
	{
		switch( event.type )
		{
			case SDL_QUIT:
					C_Input.Window = W_CLOSE;
				break;

			case SDL_KEYDOWN:
					C_Input.key = event.key.keysym.sym;
				break;

			case SDL_MOUSEBUTTONDOWN:
					C_Input.MouseButton = event.button.button;
				break;

			case SDL_MOUSEBUTTONUP:
					C_Input.MouseButton = NONE;
				break;

			case SDL_MOUSEMOTION:
					C_Input.MouseX = event.motion.x;
					C_Input.MouseY = event.motion.y;
					C_Input.MouseXRel = event.motion.xrel;
					C_Input.MouseYRel = event.motion.yrel;
				break;

			default:
					C_Input.key = NONE;
				break;
		}
	}
}

int Input::LastKeyEvent( void )
{
	return C_Input.key;
}

int Input::LastMouseEvent( void )
{
	if( C_Input.MouseButton == SDL_BUTTON_LEFT )
		return LEFT_CLICK;

	if( C_Input.MouseButton == SDL_BUTTON_RIGHT )
		return RIGHT_CLICK;

	return NONE;
}

int Input::LastWindowEvent( void )
{
	if( C_Input.Window == W_CLOSE )
		return W_CLOSE;

	return NONE;
}

int Input::MouseX( void )
{
	return C_Input.MouseX;
}

int Input::MouseY( void )
{
	return C_Input.MouseY;
}